<?php
namespace api;
use controller;

use model\tool\imageModel;
use model\bannerModel;

class banner extends controller{

    public function index(){

        $banner = [];
        if( !empty( $_GET['name'] )){
            $name = $_GET['name'];
            $banner = bannerModel::findByName( $name );
            if( !empty( $banner ) ){
                $image_list = bannerModel::findImageById( $banner['banner_id'] );
                foreach( $image_list as &$image_obj ){
                    $image_obj['image'] = imageModel::resize( $image_obj['image'], 750,370 );
                }
                $banner['image_list'] = $image_list;
            }

        }

        echo json_encode( $banner );

    }




}